/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this
work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the
"License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * *
http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is
distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific
language governing permissions and * limitations under the License. */
<template>
  <m-popover
    ref="popover"
    :ok-text="item && item.name ? $t('Edit') : $t('Submit')"
    @ok="_ok"
    @close="close"
  >
    <template slot="content">
      <div style="padding: 0 20px">
        <el-form
          ref="myform"
          :model="form"
          size="mini"
          label-position="right"
          label-width="100px"
        >
          <el-form-item
            label="申请状态"
            prop="status"
          >
            <el-radio-group
              v-model="form.status"
              size="small"
            >
              <el-radio :label="1">申请成功</el-radio>
              <el-radio :label="0">申请失败</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item
            label="备注"
            prop="remark"
          >
            <el-input
              type="input"
              v-model="form.remark"
              maxlength="60"
              size="mini"
              placeholder="请输入备注"
            > </el-input>
          </el-form-item>
        </el-form>
      </div>
    </template>
  </m-popover>
</template>
<script>
  import mPopover from '@/module/components/popup/popover'
  export default {
    name: 'check',
    data () {
      return {
        form: {
          userState: 1,
          remark: ''
        },
      }
    },
    props: {
      item: Object,
    },
    methods: {
      async _ok () {
        if (!(await this._verification())) {
          return
        }
        console.log('form', this.form)
      },
      /* 表单校验 */
      _verification () {
        return new Promise((resolve, reject) => {
          this.$refs.myform.validate((valid) => {
            resolve(!!valid)
          })
        })
      },
      close () {
        this.$emit('close')
        setTimeout(() => {
          this.$refs.myform.resetFields()
          this.$refs.myform.clearValidate()
        }, 800)
      },
    },
    created () {
      if (this.item) {
        this.form = Object.assign({}, this.form, this.item)
      }
    },
    components: { mPopover },
  }
</script>
